package com.ytjj.qmyx.mall.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.common.service.RedisService;
import com.ytjj.qmyx.mall.model.PresellSubscribeInfo;
import com.ytjj.qmyx.mall.model.dto.PresellSubscribeInfoDto;
import com.ytjj.qmyx.mall.service.PresellSubscribeInfoService;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 * 
 * @description: 苹果手机预售预约
 */
@RestController
@RequestMapping("/presellInfo")
@Slf4j
public class PresellInfoController{


    @Autowired
    PresellSubscribeInfoService presellSubscribeInfoService;

    /**
    * 预约商品
    * @param :
    * @returns: com.ytjj.common.api.CommonResult
    * 
    */
    @PostMapping("/toPreSell")
    public CommonResult toPreSell(@RequestBody PresellSubscribeInfo presellSubscribeInfo){
        boolean b = presellSubscribeInfoService.savePresell(presellSubscribeInfo);
        return CommonResult.success(b);
    }

    /**
    * 查询预约商品
    * @param :
    * @returns: com.ytjj.common.api.CommonResult
    * 
    */
    @GetMapping("/getPresellInfo/{userId}")
    public CommonResult getPresellInfo(@PathVariable Integer userId){
        PresellSubscribeInfoDto presellSubscribeInfoDto = presellSubscribeInfoService.getPresellInfo(userId);
        return CommonResult.success(presellSubscribeInfoDto);
    }

}
